package com.dst.smart.handler.disposer;

import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import android.util.Log;
import com.dst.smart.handler.entity.SemanticResult;
import com.dst.smart.handler.entity.ServiceType;
import com.dst.smart.utils.AlarmManagerUtil;
import com.dst.smart.utils.DateTimeUtil;
import com.dst.smart.utils.IdUtil;

/**
 *	预约提醒
 * 	订明天早上八点闹钟
 	订明天早上九点开会
 *
 * author <a href="http://www.xfyun.cn">讯飞开放平台</a>
 * date 2016年9月5日 下午4:58:10
 *
 */
public class SnoozeDisposer extends Disposer {

	private static final String TAG = "SnoozeDisposer";
	
	private static String KEY_ANSWER = "answer";
	private static String KEY_TEXT = "text";
	private static String KEY_CONTENT = "content";
	private static String KEY_DATETIME = "datetime";
	private static String KEY_DATE = "date";
	private static String KEY_TIME = "time";
	
	public SnoozeDisposer(Context context) {
		super(context);
	}
	
	@Override
	public void disposeResult(SemanticResult result) {
		/*
		try {
			Log.e("text","Snooze"+result.getAnswerText());

			String answer = result.getAnswerText();
			String content = result.getSemantic().getJSONObject(KEY_SLOTS).optString(KEY_CONTENT, "");
			getPlayController().playURLList(result.getUUID(),null);
			getPlayController().playText(result.getUUID(), answer + content, true, null , null);
			
			JSONObject dateTime = result.getSemantic().getJSONObject(KEY_SLOTS).getJSONObject(KEY_DATETIME);
			String date = dateTime.getString(KEY_DATE);
			String time = dateTime.getString(KEY_TIME);
			
			int[] ymd = DateTimeUtil.getClockTime(date, "-");
			int[] hsm = DateTimeUtil.getClockTime(time, ":");
			
			AlarmManagerUtil.setAlarm(mContext, IdUtil.getAlarmId("alarm"), ymd[0], ymd[1], ymd[2], hsm[0], hsm[1], hsm[2], content);

		} catch (JSONException e) {
			e.printStackTrace();
		}
		*/
	}

	@Override
	public boolean canHandle(ServiceType type) {
		return (ServiceType.SCHEDULEX.equals(type));
	}
}
